const { redis: redisConfig, mode } = require('./config')

const redis = require("redis")

let c = {
    host: redisConfig.host,
    port: redisConfig.port,
    db: redisConfig.db,
}

if(redisConfig.password) {
    c.password = redisConfig.password
}

if(redisConfig.db) {
    c.db = redisConfig.db
}

if(mode === 'dev') 
    client = null
else
    client = redis.createClient(c)


module.exports = client